/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Model;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Reynusa
 */
public class Pengiriman {
    private String KodeBarang;
    private String NamaBarang;
    private String JenisBarang;
    private int JumlahBarang;
    private double HargaBarang;
    private String KodeToko;
    private String Tgl_pengiriman;
    private String Id_pengiriman;

    public double getHargaBarang() {
        return HargaBarang;
    }

    public void setHargaBarang(double HargaBarang) {
        this.HargaBarang = HargaBarang;
    }
    
    public String getId_pengiriman() {
        return Id_pengiriman;
    }

    public void setId_pengiriman(String Id_pengiriman) {
        this.Id_pengiriman = Id_pengiriman;
    }

    public String getJenisBarang() {
        return JenisBarang;
    }

    public void setJenisBarang(String JenisBarang) {
        this.JenisBarang = JenisBarang;
    }

    public int getJumlahBarang() {
        return JumlahBarang;
    }

    public void setJumlahBarang(int JumlahBarang) {
        this.JumlahBarang = JumlahBarang;
    }

    public String getKodeBarang() {
        return KodeBarang;
    }

    public void setKodeBarang(String KodeBarang) {
        this.KodeBarang = KodeBarang;
    }

    public String getKodeToko() {
        return KodeToko;
    }

    public void setKodeToko(String KodeToko) {
        this.KodeToko = KodeToko;
    }

    public String getNamaBarang() {
        return NamaBarang;
    }

    public void setNamaBarang(String NamaBarang) {
        this.NamaBarang = NamaBarang;
    }

    public String getTgl_pengiriman() {
        return Tgl_pengiriman;
    }

    public void setTgl_pengiriman(String Tgl_pengiriman) {
        this.Tgl_pengiriman = Tgl_pengiriman;
    }
    
    public Pengiriman(){
    }
    public List lihatpengiriman(String idkirim, String tgl_kirim) throws SQLException {
        List kirim = new ArrayList();
        Connection conn = DatabaseConnect.open("jdbc:oracle:thin:@172.23.9.185:1521:orcl", "mhs125314075", "mhs125314075");
//        Connection conn = DatabaseConnect.open("jdbc:oracle:thin:@localhost:1521:xe", "hr", "12345");
//        Connection conn = DatabaseConnect.open("jdbc:oracle:thin:@localhost:1521:xe", "reynusa", "reynusa");
        String retrieveQuery = "select * from KIRIMBARANG where idkirim='" + idkirim + "' and tgl_kirim='" + tgl_kirim + "'";
        Statement st = conn.createStatement();
        ResultSet rs = st.executeQuery(retrieveQuery);
        while (rs.next()) {
            Pengiriman kirimx = new Pengiriman();
            kirimx.setKodeToko(rs.getString("kodetoko"));
            kirimx.setKodeBarang(rs.getString("kodebarang"));
            kirimx.setNamaBarang(rs.getString("namabarang"));
            kirimx.setJenisBarang(rs.getString("jenisbarang"));
            kirimx.setHargaBarang(rs.getDouble("hargabarang"));
            kirimx.setJumlahBarang(rs.getInt("jumlahbarang"));
            kirimx.setId_pengiriman(rs.getString("idkirim"));
            kirimx.setTgl_pengiriman(rs.getString("tgl_kirim"));
            kirim.add(kirimx);
        }
        conn.commit();
        return kirim;
    }
}